home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #12 / Amiga Plus CD - 2002 - No. 12.iso / AmigaOS / Aplus_Dev / AP-Website / download / pgp / pgp5gui-174b.lha / PGP5GUI-Src.lha / PGP5GUI-Src / PGPVInterface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-23  |  3.8 KB  |  168 lines

  1. /*
  2. ** PGP5GUI - A GUI using Magic User Interface v3.8
  3. **
  4. ** Copyright 23-JUNE-1998 by Stefan Zakarias, All Rights Reserved.
  5. **
  6. ** This source code is released as FREEWARE - Use it for whatever you like,
  7. ** as long as NO financial reward is gained by you for such usage.
  8. **
  9. ** If you use any parts of the this source code for anything, give ME credit
  10. ** wherever credit is due, please ;-)
  11. */
  12.  
  13. /*
  14. ** Functions to handle the interface between PGPV and the GUI
  15. */
  16.  
  17. /* Library stuff */
  18. #include <libraries/mui.h>
  19. #include <dos/dostags.h>
  20.  
  21. /* Prototypes */
  22. #ifdef __GNUC__
  23. #include <clib/muimaster_protos.h>
  24. #include <proto/alib.h>
  25. #endif
  26.  
  27. #include <proto/muimaster.h>
  28. #include <proto/exec.h>
  29. #include <clib/alib_protos.h>
  30. #include <clib/alib_stdio_protos.h>
  31. #include <proto/dos.h>
  32.  
  33. /*  Ansi  */
  34. #include <string.h>
  35.  
  36. /* Include generated by GenCodeC */
  37. #include "PGP5GUI.h"
  38.  
  39. extern char *pgp5_tmp, *pgp5_tmp_asc;
  40.  
  41. extern char *dec_files, *dec_outtype;
  42. extern char *decclippath, *decclipfile, *decclipfilename;
  43. extern char *exec_buff;
  44.  
  45. extern BOOL GetSaveASLFileName(struct ObjApp *app, char *hail, char *pathbuff, char *filebuff, char *tofile);
  46.  
  47. extern void PGP5_Execute(UBYTE *command, struct ObjApp *app);
  48. extern LONG GetCycle(Object *obj);
  49.  
  50. extern BOOL ReadClipToFile(char *tmp, struct ObjApp *app);
  51. extern BOOL WriteFileToClip(char *tmp, struct ObjApp *app);
  52.  
  53. /*
  54. ** Do the Decryption
  55. **        pgpv [-fmqv] [-z | -zs] [-o <outfile>] file ...
  56. */
  57. void
  58. Do_Decryption(struct ObjApp *App)
  59. {
  60.     char tofile[512];
  61.  
  62.     /* Title for the file requester */
  63.     char title[] = "Save Decrypted Clip To (.txt) Text File...";
  64.  
  65.     char *decfilesbuff = "\0";
  66.  
  67.     /* Values for the Cycle gadgets on the Decryption page */
  68.     LONG Dec_OUTTYPE;
  69.  
  70.     Dec_OUTTYPE = GetCycle(App->CY_Decrypt_OUTTYPE);
  71.  
  72.     *decclipfilename = '\0';
  73.  
  74.     switch (Dec_OUTTYPE)
  75.     {
  76.         case 5:        /* Decrypt/Verify from clipboard to clipboard */
  77.             if (ReadClipToFile(pgp5_tmp_asc, App))
  78.             {
  79.                 decfilesbuff = pgp5_tmp_asc;
  80.             }
  81.  
  82.             break;
  83.  
  84.         case 4:        /* Decrypt from clip to pager */
  85.         case 3:        /* Decrypt from clip to file */
  86.             if (ReadClipToFile(pgp5_tmp_asc, App))
  87.             {
  88.                 decfilesbuff = pgp5_tmp_asc;
  89.  
  90.                 if (Dec_OUTTYPE == 3)
  91.                 {
  92.                     /* Get name of file to save encrypted clip to... */
  93.                     if (GetSaveASLFileName(App, title, decclippath, decclipfile, tofile))
  94.                     {
  95.                         /* Build up the command line to send to DOS */
  96.                         sprintf(decclipfilename, " +force -o \"%s\"", tofile);
  97.                     }
  98.                     else
  99.                     {
  100.                         /* Force exit */
  101.                         decfilesbuff = "\0";
  102.                     }
  103.                 }
  104.             }
  105.  
  106.             break;
  107.  
  108.         case 2:        /* Decrypt/Verify from file to clipboard */
  109.             get(App->STR_PA_Decrypt_TOFILE,MUIA_String_Contents,&decfilesbuff);
  110.  
  111.             /* If we have a file name, then do decrypt/verify */
  112.             if (*decfilesbuff)
  113.             {
  114.                 if (WriteFileToClip(decfilesbuff, App))
  115.                 {
  116.                     if (ReadClipToFile(pgp5_tmp_asc, App))
  117.                     {
  118.                         decfilesbuff = pgp5_tmp_asc;
  119.                     }
  120.                     else
  121.                     {
  122.                         /* Force exit */
  123.                         decfilesbuff = "\0";
  124.                     }
  125.                 }
  126.                 else
  127.                 {
  128.                     /* Force exit */
  129.                     decfilesbuff = "\0";
  130.                 }
  131.             }
  132.  
  133.             break;
  134.  
  135.            default:    /* Decrypt/Verify from file  to default (file) or internal pager */
  136.             get(App->STR_PA_Decrypt_TOFILE,MUIA_String_Contents,&decfilesbuff);
  137.             break;
  138.     }
  139.  
  140.     if (*decfilesbuff)
  141.     {
  142.         strcpy(dec_files, decfilesbuff);
  143.  
  144.         if (Dec_OUTTYPE == 1 || Dec_OUTTYPE == 4)
  145.             strcpy(dec_outtype, "-m");
  146.         else
  147.             *dec_outtype = '\0';
  148.  
  149.         sprintf(exec_buff, "PGPV %s %s \"%s\"", dec_outtype, decclipfilename, dec_files);
  150.  
  151.         /* Send the command to DOS */
  152.         PGP5_Execute(exec_buff, App);
  153.  
  154.         if (Dec_OUTTYPE >= 2)
  155.         {
  156.             /* Clipboard mode...  Send the decrypted file back to the clipboard    */
  157.             if (Dec_OUTTYPE == 2 || Dec_OUTTYPE == 5)
  158.             {
  159.                 WriteFileToClip(pgp5_tmp, App);
  160.             }
  161.  
  162.             /* Delete the temporary files (T:pgp5.tmp and T:pgp5.tmp.asc) */
  163.             DeleteFile(pgp5_tmp);
  164.             DeleteFile(pgp5_tmp_asc);
  165.         }
  166.     }
  167. }
  168.